package com.itheima.UDPdemo.UDP三种通信方式.广播;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class ReceiveMessageDemo {
    public static void main(String[] args) throws IOException {

        DatagramSocket ds=new DatagramSocket(10086);

        byte[] bytes=new byte[1024];

        DatagramPacket dp=new DatagramPacket(bytes,bytes.length);
        ds.receive(dp);


        byte[] bytes1=dp.getData();
        System.out.println(new String(bytes1,0,dp.getLength()));
        System.out.println(dp.getLength());
        System.out.println(dp.getAddress());
        System.out.println(dp.getPort());

        ds.close();
    }
}
